﻿using MessageBoxNS;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

/**
 *Copyright(C) 2019 by 殊未
 *All rights reserved.
 *FileName:     
 *Author:      丁冉
 *Version:      BVP3.0
 *UnityVersion:    2018.4.0
 *Date:         #DATE#
 *Description:   
 *History:
*/

public class ColumnSetting : MonoBehaviour
{
    public UIController uIController;

    public InputField InciseColumnInput;

    /// <summary>
    /// 省列
    /// </summary>
    public InputField ProvinceInput;

    /// <summary>
    /// 市列
    /// </summary>
    public InputField CityInput;

    /// <summary>
    /// 区列
    /// </summary>
    public InputField CountyInput;

    private void Start()
    {
        InciseColumnInput.onEndEdit.AddListener(InciseColumnInputEndEdit);

        ProvinceInput.onEndEdit.AddListener(ProvinceInputEndEdit);
        CityInput.onEndEdit.AddListener(CityInputEndEdit);
        CountyInput.onEndEdit.AddListener(CountyInputEndEdit);
    }

    /// <summary>
    /// 区
    /// </summary>
    /// <param name="arg0"></param>
    private void CountyInputEndEdit(string arg0)
    {
        int a1 = 0;
        if (int.TryParse(arg0, out a1))
        {
            if (a1 < 0)
            {
                CountyInput.text = "";
                uIController.CountyIndex = null;
                MessageBox.ShowConfirmMessageBox("MessageBox", "输入大于0的数字", "知道了");
            }
            else
            {
                uIController.CountyIndex = a1;
            }
        }
        else
        {
            CountyInput.text = "";
            uIController.CountyIndex = null;
            MessageBox.ShowConfirmMessageBox("MessageBox", "输入类型不正确", "知道了");
        }
    }

    /// <summary>
    /// 市
    /// </summary>
    /// <param name="arg0"></param>
    private void CityInputEndEdit(string arg0)
    {
        int a1 = 0;
        if (int.TryParse(arg0, out a1))
        {
            if (a1 < 0)
            {
                CityInput.text = "";
                uIController.CityIndex = null;
                MessageBox.ShowConfirmMessageBox("MessageBox", "输入大于0的数字", "知道了");
            }
            else
            {
                uIController.CityIndex = a1;
            }
        }
        else
        {
            CityInput.text = "";
            uIController.CityIndex = null;
            MessageBox.ShowConfirmMessageBox("MessageBox", "输入类型不正确", "知道了");
        }
    }

    /// <summary>
    /// 省
    /// </summary>
    /// <param name="arg0"></param>
    private void ProvinceInputEndEdit(string arg0)
    {
        int a1 = 0;
        if (int.TryParse(arg0, out a1))
        {
            if (a1 < 0)
            {
                ProvinceInput.text = "";
                uIController.ProvinceIndex = null;
                MessageBox.ShowConfirmMessageBox("MessageBox", "输入大于0的数字", "知道了");
            }
            else
            {
                uIController.ProvinceIndex = a1;
            }
        }
        else
        {
            ProvinceInput.text = "";
            uIController.ProvinceIndex = null;
            MessageBox.ShowConfirmMessageBox("MessageBox", "输入类型不正确", "知道了");
        }
    }



    private void InciseColumnInputEndEdit(string arg0)
    {
        int column = -1;
        if (int.TryParse(arg0, out column))
        {
            uIController.InciseColumn = column;
            uIController.ReFreshSHowText();

        }
        else
        {
            uIController.InciseColumn = null;
        }
    }
}
